package com.example.mobile2030606150cjk0323;


import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity{
   final String tag="MyActivity";
    EditText edtTxtMainAcc,edtTxtMainPsw1,edtTxtMainPsw2,edtTxtMainPsw3;
    Button btnMainXiugai;
    String account = "abc";
    String password = "123";






    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        edtTxtMainAcc = (EditText)findViewById(R.id.edtTxt_main_acc);
        edtTxtMainPsw1 = (EditText)findViewById(R.id.edtTxt_main_psw1);
        edtTxtMainPsw2 = (EditText)findViewById(R.id.edtTxt_main_psw2);
        edtTxtMainPsw3 = (EditText)findViewById(R.id.edtTxt_main_psw3);
        btnMainXiugai =(Button)findViewById(R.id.btn_main_xiugai);




        btnMainXiugai.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name = edtTxtMainAcc.getText().toString();
                String oldpsw = edtTxtMainPsw1.getText().toString();
                String newpsw = edtTxtMainPsw2.getText().toString();
                String newpsw2 = edtTxtMainPsw3.getText().toString();
                String tag = "";
                if (TextUtils.isEmpty(name)||TextUtils.isEmpty(oldpsw)) {
                    Toast.makeText(MainActivity.this, "请输入账户密码！",Toast.LENGTH_SHORT).show();
                }else{
                    if (TextUtils.equals(name, account)) {
                        if (TextUtils.equals(oldpsw, password)) {
                            if (TextUtils.isEmpty(newpsw)||TextUtils.isEmpty(newpsw2)) {
                                Toast.makeText(MainActivity.this, "请输入密码！",Toast.LENGTH_SHORT).show();
                            }
                            else{
                                if (TextUtils.equals(newpsw,newpsw2)) {
                                    Log.i(tag, "修改成功！");

                                }
                                else {
                                    Toast.makeText(MainActivity.this, "两次输入的密码不一样！",Toast.LENGTH_SHORT).show();
                                }
                            }

                        }
                        else {
                            Toast.makeText(MainActivity.this, "密码错误！", Toast.LENGTH_SHORT).show();
                        }
                    }
                    else {
                        Toast.makeText(MainActivity.this, "账户错误！", Toast.LENGTH_SHORT).show();
                    }
                }
                }

        });
    }




}